#include "Bullet.h"
#include "Terrain.h"
#include "TankFactory.h"

CBullet::CBullet(CSceneManager* Manager, int x, int y)
{
  m_SceneManager = Manager;
  m_PositionX = x;
  m_PositionY = y;
  

  iniFactory();
  createBullet();
}
void CBullet::iniFactory()
{ /* if (m_SceneManager == NULL)
  {
    m_SceneManager = sceneManager;
    mesh = m_SceneManager->createMesh(TANK1_MESH_PATH,MESH_TYPE_MD2);

    texP = m_SceneManager->createTexture(TANK1_TEXTURE_PATH);
  }*/
  mesh = m_SceneManager->createMesh(TANK1_MESH_PATH,MESH_TYPE_MD2);

  texP = m_SceneManager->createTexture(TANK1_TEXTURE_PATH);
}

void CBullet::createBullet()
{
  msd = m_SceneManager->addMeshSceneNode(mesh,
    m_SceneManager->getRootNode(), Vector3f(static_cast<float>(m_PositionX),
    5.0f,static_cast<float>(m_PositionY)));
  msd->setTexture(texP);
  msd->setVisible(false);
}

void CBullet::update()
{
  msd->setPosition(Vector3f(static_cast<float>(m_PositionX),
    5.0f,static_cast<float>(m_PositionY)));
}

void CBullet::updatePosition()
{
  m_PositionX -= 2;
}

void CBullet::setVisible(bool visible)
{
  msd->setVisible(visible);
}
void CBullet::setXY(int x, int y)
{
  m_PositionX = x;
  m_PositionY = y;
}